Skip to content

feat(opencode): show quota usage toast after quota refresh#26

Closed
iceteaSA wants to merge 2 commits into
cortexkit:mainfrom
iceteaSA:feat/quota-toast
Closed

feat(opencode): show quota usage toast after quota refresh#26
iceteaSA wants to merge 2 commits into
cortexkit:mainfrom
iceteaSA:feat/quota-toast

Conversation

@iceteaSA
Copy link
Copy Markdown
Contributor

Summary

Displays a visual toast notification with quota usage bars after each quota cache refresh. Shows usage for both main and fallback accounts.

Example output

5h  ████████░░░░░░░░  50%
1w  ██████████████░░  87%

── work-alt ──
5h  ██████░░░░░░░░░░  38%
1w  ████████████░░░░  75%

Behavior

  • Fires after refreshMainQuotaCache completes (quota routing path)
  • Includes all enabled fallback accounts from storage
  • Toast variant scales with usage:
    • info — usage below 70%
    • warning — 70-90%
    • error — 90%+ (longer duration: 8s vs 5s)
  • Uses client.tui.showToast — gracefully no-ops if TUI is unavailable

Files changed

  • packages/opencode/src/index.ts — adds quotaBar() and showQuotaToast() utilities, calls from refreshMainQuotaCache

Testing

All 214 tests pass. Toast is fire-and-forget with .catch(() => {}) — no impact on request latency.

@iceteaSA iceteaSA force-pushed the feat/quota-toast branch from bb1169c to aec50fa Compare May 17, 2026 10:09
iceteaSA added 2 commits May 21, 2026 21:29
Unified quota cache and API gateway for main + fallback quota state.
All consumers share one QuotaManager instance for consistent caching.

Features:
- Inflight deduplication prevents concurrent API calls
- Exponential backoff (60s-15min) for 429/5xx errors
- Persists main quota and backoff state to disk via callbacks
- Cross-process file lock guard for quota API dedup
- Seeds from persisted storage on construction
- Integrates with FallbackAccountManager for shared staleness
- Captures storage path at init to prevent test config corruption
- Request-count-based refresh trigger (refreshEveryNRequests)
Displays quota usage bar notifications via client.tui.showToast after
quota data is refreshed. Shows main and fallback account usage with
visual bars, percentage, and reset time. Toast variant reflects
severity (info < 70%, warning >= 70%, error >= 90%).
@iceteaSA iceteaSA force-pushed the feat/quota-toast branch from aec50fa to 4e7ccc0 Compare May 21, 2026 19:39
@iceteaSA iceteaSA closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant